package com.jackie.coupon.customer.dao.entity;

import com.jackie.coupon.customer.api.enumss.CouponStatus;
import com.jackie.coupon.customer.dao.converter.CouponStatusConverter;
import com.jackie.coupon.template.api.beans.CouponTemplateInfo;
import lombok.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * Coupon
 *
 * @author Jackie Hou
 * @date 2023/11/18 23:18
 * @version 1.0
 */
@Entity
@Table(name = "coupon")
@EntityListeners(AuditingEntityListener.class)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Coupon {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;


    @Column(name = "template_id", nullable = false)
    private Long templateId;


    @Column(name="user_id", nullable = false)
    private Long userId;


    @Column(name = "shop_id")
    private Long shopId;


    @CreatedDate
    @Column(name = "created_time")
    private Date createdTime;


    @Column(name = "status", nullable = false)
    @Convert(converter = CouponStatusConverter.class)
    private CouponStatus status;


    @Transient
    private CouponTemplateInfo templateInfo;





}
